GtkWidgetPath: Show states in the path string
authorMatthias Clasen <mclasen@redhat.com>
Mon, 21 Jul 2014 23:49:11 +0000 (19:49 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 21 Jul 2014 23:49:11 +0000 (19:49 -0400)
This shows clearly that some widgets don't set the state on their
path currently.

gtk/gtkwidgetpath.c

index 40d29721e08d7a4f9094698e6b80a19da5474ce4..ba94a7fb2eeadb10501f6b2e6dfb91ca98021c7e 100644 (file)
@@ -22,6 +22,7 @@
 #include "gtkwidget.h"
 #include "gtkwidgetpath.h"
 #include "gtkstylecontextprivate.h"
+#include "gtktypebuiltins.h"
 
 /**
  * SECTION:gtkwidgetpath
@@ -327,6 +328,28 @@ gtk_widget_path_to_string (const GtkWidgetPath *path)
           g_string_append_c (string, ')');
         }
 
+      if (elem->state)
+        {
+          GFlagsClass *fclass;
+          gint i;
+          gboolean appended;
+
+          appended = FALSE;
+          fclass = g_type_class_ref (GTK_TYPE_STATE_FLAGS);
+          g_string_append_c (string, '[');
+          for (i = 0; i < fclass->n_values; i++)
+            {
+              if (elem->state & fclass->values[i].value)
+                {
+                  if (appended)
+                    g_string_append_c (string, '|');
+                  g_string_append (string, fclass->values[i].value_nick);
+                  appended = TRUE;
+                }
+            }
+          g_string_append_c (string, ']');
+          g_type_class_unref (fclass);
+        }
 
       if (elem->siblings)
         g_string_append_printf (string, "[%d/%d]",